import QtQuick 2.0
import QtQuick.Layouts 1.11
import QtQuick.Controls 2.15

import QtQuick.Window 2.1
import QtQuick.Controls.Material 2.1




ApplicationWindow {
    id: window
    width: 1027
       height: 480


    property var someObject:  {  "添加" :"","关于":"" }


    visible: true
    StackView {
        id: stack;
        anchors.centerIn: parent;
        width: 600;
        height: 300;
        property var home: null;

    }

     menuBar: MenuBar {

        Menu {

            id:menu;
            title: "门诊登记"
            MenuItem{
                id:login;
                text: "添加";
                onTriggered: {
                    stack.push("123.qml")
                    Qt.createComponent("123.qml")
                    if ( someObject["添加"] === ""){
                var tab = tabButton.createObject(tabBar, {text: text})
                console.log(someObject["添加"])
                someObject["添加"] = tabBar.count
                    tabBar.setCurrentIndex(someObject["添加"] -1 )}else{
                        console.log(someObject["添加"])
                    tabBar.setCurrentIndex(someObject["添加"] -1 )}

                }


            }

        }
        Menu {
            id:menu2;
            title: "帮助";
            MenuItem{
                text: "关于";
                onTriggered: {
                    if ( someObject["关于"] === ""){
                var tab = tabButton.createObject(tabBar, {text: text})
                console.log(someObject["关于"])
                someObject["关于"] = tabBar.count
                    tabBar.setCurrentIndex(someObject["关于"] -1 )}else{
                        console.log(someObject["关于"])
                    tabBar.setCurrentIndex(someObject["关于"] -1 )}

                }


            }
            MenuItem{
                text: "官网";
                onTriggered: {
                    var tab = tabButton.createObject(tabBar, {text: text})
      }

            }
        }
    }
    TabBar {
        id:tabBar
        width: parent.width
        TabButton {
            text: "home" }
        Component {
             id: tabButton
             TabButton {
                 text: "home" }


         }



       }
    Button{


        onClicked: {
                tabBar.setCurrentIndex(0)

            rect.destroy();
//                console.log(StackView.index)
//                StackView

               }
    }
}


